package com.denlaku.longan.service.impl;

import com.denlaku.longan.anno.RequiredTx;
import com.denlaku.longan.qo.DashboardHisQuery;
import com.denlaku.longan.qo.Query;
import com.denlaku.longan.repository.DashboardHisRepository;
import com.denlaku.longan.service.DashboardHisService;
import com.denlaku.longan.util.SnowflakeUtils;
import com.denlaku.longan.vo.DashboardHis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author tianx
 */
@Service
public class DashboardHisServiceImpl implements DashboardHisService {
    @Autowired
    private DashboardHisRepository dashboardHisRepository;

    /**
     * 添加仪表板历史记录
     * @param dashboardHis 仪表板历史记录
     */
    @Override
    @RequiredTx
    public void add(DashboardHis dashboardHis) {
        dashboardHis.setId(SnowflakeUtils.nextId());
        dashboardHisRepository.add(dashboardHis);
    }

    /**
     * 删除仪表板历史记录
     * @param query 查询参数
     */
    @Override
    @RequiredTx
    public void delete(DashboardHisQuery query) {
        dashboardHisRepository.delete(query);
    }

    /**
     * 查询仪表板历史记录
     * @param query 查询参数
     * @return 仪表板历史记录
     */
    @Override
    public DashboardHis get(Query query) {
        return dashboardHisRepository.get(query);
    }
    /**
     * 查询仪表板历史记录
     * @param query 查询参数
     * @return 仪表板历史记录
     */
    @Override
    public List<DashboardHis> list(DashboardHisQuery query) {
        return dashboardHisRepository.list(query);
    }

}
